A simple tutorial using SpatialQPFs library to extract spatial features based on cell level data from images

Xiao Li xiao.li.xl2@roche.com

2025-10-19

Introduction

This Rmarkdown file provides a simple tutorial on how to use the functions in SpatialQPFs R library to calculate the features to decipher spatial relationship between different cell types, from spatial statistics and graph topology perspective.

How to use the functions in SpatialQPFs

Firstly, let’s simulate a synthetic dataset to begin with. In reality, to extract detailed cell-level information, users must preprocess the digital image. This preprocessing step involves isolating key information such as cell coordinates and cell identity from a variety of digital slides, which can encompass images stained with H\(\&\)E, Immunohistochemistry, or Immunofluorescence techniques, as well as spatially resolved single-cell imaging.

library('SpatialQPFs')
library('data.table')
library('dplyr')

set.seed(42)

# library('ggplot2')
# 
# # --- 1. Set Parameters ---
# 
# # Set a seed for reproducibility
# set.seed(42)
# 
# # Define the number of cells for each region
# n_main <- 2000      # Cells in the general tumor microenvironment
# n_hotspot <- 300    # Cells in the lymphocyte-infiltrated hotspot
# n_stroma <- 500     # Cells in the stroma-dense region
# 
# # Define the four cell types
# cell_types <- c("TC", "Lym", "Stroma", "Others")
# 
# 
# # --- 2. Generate Data for Each Spatial Region ---
# 
# # Region 1: General Tumor Microenvironment (TME)
# # High proportion of TC, moderate Stroma, low Lym and Others.
# dat_main <- data.frame(
#   x = round(runif(n = n_main, min = 1, max = 10000)),
#   y = round(runif(n = n_main, min = 1, max = 10000)),
#   cell_id = sample(
#     cell_types,
#     size = n_main,
#     replace = TRUE,
#     prob = c(0.50, 0.10, 0.30, 0.10) # 50% TC, 10% Lym, 30% Stroma, 10% Others
#   )
# )
# 
# # Region 2: Lymphocyte-rich Hotspot
# # Simulates a strong immune infiltrate with a very high proportion of Lymphocytes.
# dat_hotspot <- data.frame(
#   x = round(runif(n = n_hotspot, min = 1500, max = 4000)),
#   y = round(runif(n = n_hotspot, min = 1500, max = 4000)),
#   cell_id = sample(
#     cell_types,
#     size = n_hotspot,
#     replace = TRUE,
#     prob = c(0.10, 0.70, 0.15, 0.05) # 10% TC, 70% Lym, 15% Stroma, 5% Others
#   )
# )
# 
# # Region 3: Stroma-dense Area
# # Simulates surrounding connective tissue with a high proportion of Stroma.
# dat_stroma <- data.frame(
#   x = round(runif(n = n_stroma, min = 6000, max = 9500)),
#   y = round(runif(n = n_stroma, min = 5000, max = 8500)),
#   cell_id = sample(
#     cell_types,
#     size = n_stroma,
#     replace = TRUE,
#     prob = c(0.15, 0.05, 0.75, 0.05) # 15% TC, 5% Lym, 75% Stroma, 5% Others
#   )
# )
# 
# 
# # --- 3. Combine and Finalize Data ---
# 
# # Combine the data frames from all regions
# dat <- rbind(dat_main, dat_hotspot, dat_stroma)
# 
# # Shuffle the rows to ensure the data isn't ordered by region
# dat <- dat[sample(nrow(dat)), ]
# 
# colnames(dat) <- c("x", "y", "cell_id")
# 
# 
# # --- 4. Visualize the Generated Data ---
# 
# # Create a scatter plot to visualize the spatial distribution of cell types
# cell_plot <- ggplot(dat, aes(x = x, y = y, color = cell_id)) +
#   geom_point(alpha = 0.8, size = 1.5) +
#   coord_fixed() + # Ensure the aspect ratio is 1:1
#   scale_color_manual(values = c(
#     "TC" = "firebrick",
#     "Lym" = "steelblue",
#     "Stroma" = "forestgreen",
#     "Others" = "grey50"
#   )) +
#   labs(
#     title = "Spatially Simulated Cell Data",
#     x = "X Coordinate",
#     y = "Y Coordinate",
#     color = "Cell Type"
#   ) +
#   theme_minimal() +
#   theme(
#     legend.position = "bottom",
#     plot.title = element_text(hjust = 0.5, face = "bold", size = 16)
#   )
# 
# # Print the plot
# print(cell_plot)
# 
# # Display the first few rows of the final data frame
# print(head(dat))
# 
# write.csv(dat, '/Users/lix233/SpatialQPFs_2.0.0/inst/extdata/dat.csv', row.names = F)

dat = read.csv(system.file("extdata", "dat.csv", package = "SpatialQPFs"))


cat("The first 20 cell in the example csv file looks like:")
## The first 20 cell in the example csv file looks like:
dat[1:20,]
##       x    y cell_id
## 1  3779 8206      TC
## 2  2655  470      TC
## 3  1088 5104  Stroma
## 4  7313 4994  Stroma
## 5  8735 7233      TC
## 6  9450 9375  Others
## 7   597 5852  Stroma
## 8  2679 4492      TC
## 9  1786 2610     Lym
## 10 9792 8173      TC
## 11 1297 1465     Lym
## 12 4142 6521      TC
## 13 2908 1577  Stroma
## 14 1601 2656     Lym
## 15 7149 4428      TC
## 16 1888 2316  Others
## 17 9471 5543      TC
## 18 8537 7951  Stroma
## 19 1252 9848  Others
## 20 9819 7061      TC

Visualization of the raw cell data and its spatial density plot

Now we have the generated the data, we want to visualize the cell data, this can be done by calling Data_Vis() function.

We look at “Lym” cell type first:

path = gsub("dat.csv", "", system.file("extdata", "dat.csv", package = "SpatialQPFs"))
# print(paste0("Your file path is: ", path))
file = "dat.csv"

Data_Vis(path = path, file = file, cell_class_var = "cell_id", x_var = "x", y_var = "y", cell_type = "Lym")  

Next, “TC” cell type:

Data_Vis(path = path, file = file, cell_class_var = "cell_id", x_var = "x", y_var = "y", cell_type = "TC")  

Next, “Stroma” cell type:

Data_Vis(path = path, file = file, cell_class_var = "cell_id", x_var = "x", y_var = "y", cell_type = "Stroma")  

Next, “Others” cell type:

Data_Vis(path = path, file = file, cell_class_var = "cell_id", x_var = "x", y_var = "y", cell_type = "Others")  

Point pattern data analysis

To utilize spatial point process methods, SpatialQPFs provides 3 functions:

For “Lym” cell type spatial features:

ss_point_uni_Lym = Point_pattern_data_uni(path = path, file = file, x_var = "x", y_var = "y", cell_class_var = "cell_id", cell_type = "Lym", scale = 500, myplot = T)

print(ss_point_uni_Lym)
## $g_AUC
## [1] 0.004661152
## 
## $g_r
## [1] 0.05066369
## 
## $k_AUC
## [1] 0.0003789604
## 
## $k_vals_med
##        50% 
## 0.00789986 
## 
## $k_vals_q1
##        25% 
## 0.00198158 
## 
## $k_vals_q3
##        75% 
## 0.01722362 
## 
## $k_vals_max
## [1] 0.02926199
## 
## $pcf_AUC
## [1] 0.1330209
## 
## $pcf_vals_med
##      50% 
## 3.776434 
## 
## $pcf_vals_q1
##     25% 
## 3.49762 
## 
## $pcf_vals_q3
##      75% 
## 3.913852 
## 
## $pcf_vals_max
## [1] 5.176213
## 
## $pcf_vals_min
## [1] 3.383061
## 
## $pcf_r
## [1] 0.00266651
## 
## $CE
##    naive 
## 0.890238

For “TC” cell type spatial features:

ss_point_uni_TC = Point_pattern_data_uni(path = path, file = file, x_var = "x", y_var = "y", cell_class_var = "cell_id", cell_type = "TC", scale = 500, myplot = T)

print(ss_point_uni_TC)
## $g_AUC
## [1] -3.399809e-05
## 
## $g_r
## [1] 0.04474579
## 
## $k_AUC
## [1] 7.373894e-06
## 
## $k_vals_med
##         50% 
## 0.002108313 
## 
## $k_vals_q1
##          25% 
## 0.0005112325 
## 
## $k_vals_q3
##         75% 
## 0.004734315 
## 
## $k_vals_max
## [1] 0.008146708
## 
## $pcf_AUC
## [1] 0.002099142
## 
## $pcf_vals_med
##      50% 
## 1.067271 
## 
## $pcf_vals_q1
##       25% 
## 0.9994965 
## 
## $pcf_vals_q3
##     75% 
## 1.08681 
## 
## $pcf_vals_max
## [1] 1.106596
## 
## $pcf_vals_min
## [1] 0.7911587
## 
## $pcf_r
## [1] 0.01052842
## 
## $CE
##    naive 
## 1.008257

For “Stroma” cell type spatial features:

ss_point_uni_Lym = Point_pattern_data_uni(path = path, file = file, x_var = "x", y_var = "y", cell_class_var = "cell_id", cell_type = "Stroma", scale = 500, myplot = T)

print(ss_point_uni_Lym)
## $g_AUC
## [1] 0.00104726
## 
## $g_r
## [1] 0.05001
## 
## $k_AUC
## [1] 0.0001153919
## 
## $k_vals_med
##         50% 
## 0.003684848 
## 
## $k_vals_q1
##          25% 
## 0.0009141326 
## 
## $k_vals_q3
##         75% 
## 0.008340983 
## 
## $k_vals_max
## [1] 0.01473958
## 
## $pcf_AUC
## [1] 0.04155797
## 
## $pcf_vals_med
##     50% 
## 1.87003 
## 
## $pcf_vals_q1
##     25% 
## 1.84434 
## 
## $pcf_vals_q3
##      75% 
## 1.902831 
## 
## $pcf_vals_max
## [1] 1.979815
## 
## $pcf_vals_min
## [1] 1.781335
## 
## $pcf_r
## [1] 0.002632105
## 
## $CE
##     naive 
## 0.9585885

For “Others” cell type spatial features:

ss_point_uni_Lym = Point_pattern_data_uni(path = path, file = file, x_var = "x", y_var = "y", cell_class_var = "cell_id", cell_type = "Others", scale = 500, myplot = T)

print(ss_point_uni_Lym)
## $g_AUC
## [1] -0.002346612
## 
## $g_r
## [1] 0.05021089
## 
## $k_AUC
## [1] -1.958382e-05
## 
## $k_vals_med
##         50% 
## 0.001847102 
## 
## $k_vals_q1
##          25% 
## 0.0003459852 
## 
## $k_vals_q3
##         75% 
## 0.003609473 
## 
## $k_vals_max
## [1] 0.007333462
## 
## $pcf_AUC
## [1] -0.005840654
## 
## $pcf_vals_med
##       50% 
## 0.8691311 
## 
## $pcf_vals_q1
##       25% 
## 0.7951248 
## 
## $pcf_vals_q3
##       75% 
## 0.9635727 
## 
## $pcf_vals_max
## [1] 1.104238
## 
## $pcf_vals_min
## [1] 0.6671293
## 
## $pcf_r
## [1] 0.04492553
## 
## $CE
##    naive 
## 1.130428

For spatial interaction features between “TC” and “Lym”:

ss_point_bi = Point_pattern_data_bi(path = path, 
                                    file = file, x_var = "x", y_var = "y", cell_class_var = "cell_id", 
                                    from_type = "Lym", 
                                    to_type = "TC", 
                                    scale = 500, myplot = T)

## Cross type G-function is calculated.

## Cross type K-function is calculated. 
## 1, 
## 2.

## Differences in Ripley's K-function is calculated.

## Pair correlation function is calculated.

## Mark correlation function is calculated.

## Mark connection function is calculated.

## Marcon and Puech's M function is calculated.
print(ss_point_bi)
## $g_cross_AUC
## [1] 0.0006782376
## 
## $g_cross_r
## [1] 0.03889667
## 
## $k_cross_AUC
## [1] 2.426612e-05
## 
## $k_cross_vals_med
##         50% 
## 0.002336459 
## 
## $k_cross_vals_q1
##          25% 
## 0.0005660821 
## 
## $k_cross_vals_q3
##         75% 
## 0.005277495 
## 
## $k_cross_vals_max
## [1] 0.00944047
## 
## $K12_Diff_AUC
## [1] 0.0003790916
## 
## $k_k1k2_vals_med
##        50% 
## 0.00594408 
## 
## $k_k1k2_vals_q1
##         25% 
## 0.001634323 
## 
## $k_k1k2_vals_q3
##        75% 
## 0.01270813 
## 
## $k_k1k2_vals_max
## [1] 0.02151166
## 
## $K1K12_Diff_AUC
## [1] 0.0003633184
## 
## $k_k1k12_vals_med
##         50% 
## 0.005750551 
## 
## $k_k1k12_vals_q1
##         25% 
## 0.001602771 
## 
## $k_k1k12_vals_q3
##       75% 
## 0.0122064 
## 
## $k_k1k12_vals_max
## [1] 0.02026278
## 
## $K2K12_Diff_AUC
## [1] -1.577328e-05
## 
## $k_k2k12_vals_med
##           50% 
## -0.0001935285 
## 
## $k_k2k12_vals_q1
##           25% 
## -0.0005017328 
## 
## $k_k2k12_vals_q3
##           75% 
## -3.155209e-05 
## 
## $k_k2k12_vals_max
## [1] 0
## 
## $pcf_AUC
## [1] 0.008457301
## 
## $pcf_vals_med
##     50% 
## 1.21454 
## 
## $pcf_vals_q1
##      25% 
## 1.168805 
## 
## $pcf_vals_q3
##     75% 
## 1.22244 
## 
## $pcf_vals_max
## [1] 1.229431
## 
## $pcf_vals_min
## [1] 1.091761
## 
## $pcf_r
## [1] 0.04445334
## 
## $mrcf_AUC
## [1] 0.01127915
## 
## $mrcf_vals_med
##      50% 
## 1.228653 
## 
## $mrcf_vals_q1
##     25% 
## 1.20611 
## 
## $mrcf_vals_q3
##      75% 
## 1.274725 
## 
## $mrcf_vals_max
## [1] 1.277776
## 
## $mrcf_vals_min
## [1] 0.8980466
## 
## $mrcf_r
## [1] 0.02778333
## 
## $mccf_AUC
## [1] -0.0003683821
## 
## $mccf_vals_med
##        50% 
## 0.05376596 
## 
## $mccf_vals_q1
##        25% 
## 0.05269271 
## 
## $mccf_vals_q3
##        75% 
## 0.05565426 
## 
## $mccf_vals_max
## [1] 0.05800203
## 
## $mccf_vals_min
## [1] 0.04952488
## 
## $mccf_r
## [1] 0.04445334
## 
## $M_AUC
## [1] 0.1063055
## 
## $M_vals_med
##      50% 
## 3.591923 
## 
## $M_vals_q1
##      25% 
## 3.280865 
## 
## $M_vals_q3
##      75% 
## 4.116922 
## 
## $M_vals_max
## [1] 4.611528
## 
## $M_vals_min
## [1] 0.4818792
## 
## $M_r
## [1] 0.03334
ss_point_ITLR = Point_pattern_data_ITLR(path = path, 
                                        file = file, x_var = "x", y_var = "y", cell_class_var = "cell_id", 
                                        from_type = "Lym", 
                                        to_type = "TC", 
                                        micron_per_pixel = 0.5, 
                                        myplot = T)
## Xrange is  1 4998 
## Yrange is  1 4974 
## Doing quartic kernel

print(ss_point_ITLR)
## $ITLR
## [1] 0.1852679
## 
## $ITLR2
## [1] 0.07706592

Areal data

To utilize spatial lattice process methods, SpatialQPFs provides Areal_data() function. For details of the function, refer to help(Areal_data)

ss_lattice_bi = Areal_data(path = path, file = file, 
                           x_var = "x", y_var = "y", cell_class_var = "cell_id", 
                           from_type = "Lym", 
                           to_type = "TC", 
                           scale = 200, 
                           myplot = T)

## Areal features are calculated.
print(ss_lattice_bi)
## $BC
## [1] 0.5185003
## 
## $MH_index
## [1] 0.3257691
## 
## $JaccardJ
## [1] 0.2122787
## 
## $SorensenL
## [1] 0.3502143
## 
## $Moran_I_tumor
## [1] 0.03291831
## 
## $Moran_I_immune
## [1] 0.6420521
## 
## $moran_I_Bivariate
## [1] 0.06693746
## 
## $geary_TC
## [1] 0.9751893
## 
## $geary_IC
## [1] 0.5006019
## 
## $moran_HL_TC
## [1] 0.003676471
## 
## $moran_HH_TC
## [1] 0.02573529
## 
## $moran_LH_TC
## [1] 0.009191176
## 
## $moran_LL_TC
## [1] 0.003676471
## 
## $geary_HH_TC
## [1] 0.02389706
## 
## $geary_LL_TC
## [1] 0.003676471
## 
## $geary_OP_TC
## [1] 0.009191176
## 
## $geary_NE_TC
## [1] 0.007352941
## 
## $moran_HL_IC
## [1] 0
## 
## $moran_HH_IC
## [1] 0.07352941
## 
## $moran_LH_IC
## [1] 0.007352941
## 
## $moran_LL_IC
## [1] 0
## 
## $geary_HH_IC
## [1] 0.06617647
## 
## $geary_LL_IC
## [1] 0
## 
## $geary_OP_IC
## [1] 0.003676471
## 
## $geary_NE_IC
## [1] 0
## 
## $moran_HH_TC_HH_IC
## [1] 0.001102941
## 
## $moran_HH_TC_HL_IC
## [1] 0
## 
## $moran_HH_TC_LH_IC
## [1] 0
## 
## $moran_HH_TC_LL_IC
## [1] 0
## 
## $moran_HL_TC_HH_IC
## [1] 0
## 
## $moran_HL_TC_HL_IC
## [1] NA
## 
## $moran_HL_TC_LH_IC
## [1] 0
## 
## $moran_HL_TC_LL_IC
## [1] 0
## 
## $moran_LH_TC_HH_IC
## [1] 0.0003676471
## 
## $moran_LH_TC_HL_IC
## [1] 0
## 
## $moran_LH_TC_LH_IC
## [1] 0
## 
## $moran_LH_TC_LL_IC
## [1] 0
## 
## $moran_LL_TC_HH_IC
## [1] 0
## 
## $moran_LL_TC_HL_IC
## [1] NA
## 
## $moran_LL_TC_LH_IC
## [1] 0
## 
## $moran_LL_TC_LL_IC
## [1] 0
## 
## $geary_HH_TC_HH_IC
## [1] 0.005514706
## 
## $geary_HH_TC_LL_IC
## [1] 0
## 
## $geary_HH_TC_OP_IC
## [1] 0
## 
## $geary_HH_TC_NE_IC
## [1] 0
## 
## $geary_LL_TC_HH_IC
## [1] 0
## 
## $geary_LL_TC_LL_IC
## [1] 0
## 
## $geary_LL_TC_OP_IC
## [1] 0
## 
## $geary_LL_TC_NE_IC
## [1] NA
## 
## $geary_OP_TC_HH_IC
## [1] 0
## 
## $geary_OP_TC_LL_IC
## [1] 0
## 
## $geary_OP_TC_OP_IC
## [1] 0
## 
## $geary_OP_TC_NE_IC
## [1] 0
## 
## $geary_NE_TC_HH_IC
## [1] 0
## 
## $geary_NE_TC_LL_IC
## [1] 0
## 
## $geary_NE_TC_OP_IC
## [1] 0
## 
## $geary_NE_TC_NE_IC
## [1] NA
## 
## $GetisOrd_HS
## [1] 0.009191176
## 
## $GetisOrd_CS
## [1] 0
## 
## $GetisOrd_CS_IC_HS_TC
## [1] 0
## 
## $GetisOrd_CS_TC_HS_IC
## [1] 0
## 
## $GetisOrd_HS_IC
## [1] 0.07536765
## 
## $GetisOrd_CS_IC
## [1] 0.005514706
## 
## $GetisOrd_HS_TC
## [1] 0.04044118
## 
## $GetisOrd_CS_TC
## [1] 0.01286765
## 
## $GetisOrd_S_intra_cancer
## [1] 0.9998912
## 
## $GetisOrd_S_intra_immune
## [1] 0.9998912
## 
## $Lee_L
## [1] 0.1589278
## 
## $Lee_HL_TC_IC
## [1] 0.005514706
## 
## $Lee_HH_TC_IC
## [1] 0.04779412
## 
## $Lee_LH_TC_IC
## [1] 0.01838235
## 
## $Lee_LL_TC_IC
## [1] 0.003676471
## 
## $Lee_HL_IC_TC
## [1] 0.02205882
## 
## $Lee_HH_IC_TC
## [1] 0.04227941
## 
## $Lee_LH_IC_TC
## [1] 0.005514706
## 
## $Lee_LL_IC_TC
## [1] 0.005514706

Geostatistics data

To utilize geostatistics process methods, SpatialQPFs provides Geostatistics_data() function. For details of the function, refer to help(Geostatistics_data)

ss_geostat_bi = Geostatistics_data(path = path, file = file, 
                                   x_var = "x", y_var = "y", cell_class_var = "cell_id", 
                                   from_type = "Lym", 
                                   to_type = "TC", 
                                   scale = 500, 
                                   myplot = T)

## Geostatistics features are calculated.
print(ss_geostat_bi)
## $sill_tumor
## [1] 1.22331e-05
## 
## $sill_immune
## [1] 0.0003285947
## 
## $range_tumor
## [1] 0.03298128
## 
## $range_immune
## [1] 0.03490245
## 
## $kappa_tumor
## [1] 1
## 
## $kappa_immune
## [1] 5
## 
## $sill_IC_TC
## [1] 0.0003022043
## 
## $range_IC_TC
## [1] 0.03243775
## 
## $kappa_IC_TC
## [1] 5
## 
## $sill_TC_IC
## [1] 1.153167e-05
## 
## $range_TC_IC
## [1] 0.01435864
## 
## $kappa_TC_IC
## [1] 4.2
## 
## $kappa_IK
## [1] 1
## 
## $sill_IK
## [1] 0.2637792
## 
## $range_IK
## [1] 0.1928726

Graph data

graph_uni_TC = DT_graph_uni_subregion_random(path = path, file = file, 
                                   x_var = "x", y_var = "y", cell_class_var = "cell_id", 
                                   cell_type = "TC", 
                                   scale = 1000, side_length = 2000, num_FOV = 20, set_seed = 42, myplot = T)
## [1] 1

## [1] 2

## [1] 3

## [1] 4

## [1] 5

## [1] 6

## [1] 7

## [1] 8

## [1] 9

## [1] 10

## [1] 11

## [1] 12

## [1] 13

## [1] 14

## [1] 15

## [1] 16

## [1] 17

## [1] 18

## [1] 19

## [1] 20

graph_uni_Lym = DT_graph_uni_subregion_random(path = path, file = file, 
                                   x_var = "x", y_var = "y", cell_class_var = "cell_id", 
                                   cell_type = "Lym", 
                                   scale = 1000, side_length = 2000, num_FOV = 20, set_seed = 42, myplot = T)
## [1] 1

## [1] 2

## [1] 3

## [1] 4

## [1] 5

## [1] 6

## [1] 7

## [1] 8

## [1] 9

## [1] 10

## [1] 11

## [1] 12

## [1] 13

## [1] 14

## [1] 15

## [1] 16

## [1] 17

## [1] 18

## [1] 19

## [1] 20

graph_all = DT_graph_cross_subregion_random(path = path, file = file, 
                                   x_var = "x", y_var = "y", cell_class_var = "cell_id", 
                                   cell_type = c("TC", "Lym", "Stroma", "Others"), 
                                   scale = 1000, side_length = 2000, num_FOV = 20, set_seed = 42, myplot = T)
## Processing FOV: 1

## Processing FOV: 2

## Processing FOV: 3

## Processing FOV: 4

## Processing FOV: 5

## Processing FOV: 6

## Processing FOV: 7

## Processing FOV: 8

## Processing FOV: 9

## Processing FOV: 10

## Processing FOV: 11

## Processing FOV: 12

## Processing FOV: 13

## Processing FOV: 14

## Processing FOV: 15

## Processing FOV: 16

## Processing FOV: 17

## Processing FOV: 18

## Processing FOV: 19

## Processing FOV: 20

Entropy measurements

Spatial Entropy using all cell types

spat_entropy_all = spat_entropy_alltype(path = path, file = file, 
                                        cell_class_var = "cell_id", 
                                        x_var = "x", y_var = "y", scale = 200, 
                                        side_length = 2000, num_FOV = 10, set_seed = 42, myplot = T)
## [1] 1
## Computing the pairwise distances for all observations. This may take some time...
## All done

## Computing the pairwise distances for all observations. This may take some time...
## Done

## [1] 2
## Computing the pairwise distances for all observations. This may take some time...
## All done

## Computing the pairwise distances for all observations. This may take some time...
## Done

## [1] 3
## Computing the pairwise distances for all observations. This may take some time...
## All done

## Computing the pairwise distances for all observations. This may take some time...
## Done

## [1] 4
## Computing the pairwise distances for all observations. This may take some time...
## All done

## Computing the pairwise distances for all observations. This may take some time...
## Done

## [1] 5
## Computing the pairwise distances for all observations. This may take some time...
## All done

## Computing the pairwise distances for all observations. This may take some time...
## Done

## [1] 6
## Computing the pairwise distances for all observations. This may take some time...
## All done

## Computing the pairwise distances for all observations. This may take some time...
## Done

## [1] 7
## Computing the pairwise distances for all observations. This may take some time...
## All done

## Computing the pairwise distances for all observations. This may take some time...
## Done

## [1] 8
## Computing the pairwise distances for all observations. This may take some time...
## All done

## Computing the pairwise distances for all observations. This may take some time...
## Done

## [1] 9
## Computing the pairwise distances for all observations. This may take some time...
## All done

## Computing the pairwise distances for all observations. This may take some time...
## Done

## [1] 10
## Computing the pairwise distances for all observations. This may take some time...
## All done

## Computing the pairwise distances for all observations. This may take some time...
## Done

print(spat_entropy_all)
## $shannon
## [1] 1.198687
## 
## $shannonZ_entropy
## [1] 1.93634
## 
## $altieri_entropy_SMI
## [1] 0.06840236
## 
## $altieri_entropy_RES
## [1] 1.85931
## 
## $leibovici_entropy
## [1] 2.27181
## 
## $spat_diversity
## [1] 1.649454

Spatial Entropy using one cell type

spat_entropy_TC = spat_entropy_onetype(path = path, file = file, 
                                       cell_class_var = "cell_id", 
                                       x_var = "x", y_var = "y", 
                                       cell_type = "TC", 
                                       scale = 200, myplot = T)

print(spat_entropy_TC)
## $batty_entropy
## [1] -0.3319566
## 
## $battyLISA_entropy
## [1] 6.262947
spat_entropy_Lym = spat_entropy_onetype(path = path, file = file, 
                                       cell_class_var = "cell_id", 
                                       x_var = "x", y_var = "y", 
                                       cell_type = "Lym", 
                                       scale = 200, myplot = T)

print(spat_entropy_Lym)
## $batty_entropy
## [1] -1.285927
## 
## $battyLISA_entropy
## [1] 5.580511

Local Entropy

spat_local_entropy = local_entropy(path = path, file = file, 
                                   cell_class_var = "cell_id", 
                                   x_var = "x", y_var = "y", 
                                   scale = 200, myplot = T)

spat_local_entropy_TC = spat_local_entropy[dat$cell_id == "TC"]

spat_local_entropy_Lym  = spat_local_entropy[dat$cell_id == "Lym"]
  
# print(spat_local_entropy)  

Aggregating spatial feature outputs for downstream analysis

this_res = data.frame(cbind(data.frame("file" = file),
                            data.frame(ss_point_uni_TC) %>% setnames(paste0(names(.),"_TC")), 
                            data.frame(ss_point_uni_Lym) %>% setnames(paste0(names(.),"_Lym")), 
                            data.frame(ss_point_bi), 
                            data.frame(ss_point_ITLR), 
                            data.frame(ss_lattice_bi), 
                            data.frame(ss_geostat_bi),
                            data.frame(graph_uni_TC) %>% setnames(paste0(names(.),"_TC")),
                            data.frame(graph_uni_Lym) %>% setnames(paste0(names(.),"_Lym")),
                            data.frame(graph_all), 
                            data.frame(spat_entropy_all),
                            data.frame(spat_entropy_TC) %>% setnames(paste0(names(.),"_TC")),
                            data.frame(spat_entropy_Lym) %>% setnames(paste0(names(.),"_Lym")),
                            distribution_summary(spat_local_entropy_TC[!is.na(spat_local_entropy_TC)]) %>% setnames(paste0(names(.),"_le_TC")),
                            distribution_summary(spat_local_entropy_Lym[!is.na(spat_local_entropy_Lym)]) %>% setnames(paste0(names(.),"_le_Lym"))
                            ),
                      row.names = NULL)

print(this_res)
##      file      g_AUC_TC     g_r_TC     k_AUC_TC k_vals_med_TC k_vals_q1_TC
## 1 dat.csv -3.399809e-05 0.04474579 7.373894e-06   0.002108313 0.0005112325
##   k_vals_q3_TC k_vals_max_TC  pcf_AUC_TC pcf_vals_med_TC pcf_vals_q1_TC
## 1  0.004734315   0.008146708 0.002099142        1.067271      0.9994965
##   pcf_vals_q3_TC pcf_vals_max_TC pcf_vals_min_TC   pcf_r_TC    CE_TC
## 1        1.08681        1.106596       0.7911587 0.01052842 1.008257
##      g_AUC_Lym    g_r_Lym     k_AUC_Lym k_vals_med_Lym k_vals_q1_Lym
## 1 -0.002346612 0.05021089 -1.958382e-05    0.001847102  0.0003459852
##   k_vals_q3_Lym k_vals_max_Lym  pcf_AUC_Lym pcf_vals_med_Lym pcf_vals_q1_Lym
## 1   0.003609473    0.007333462 -0.005840654        0.8691311       0.7951248
##   pcf_vals_q3_Lym pcf_vals_max_Lym pcf_vals_min_Lym  pcf_r_Lym   CE_Lym
## 1       0.9635727         1.104238        0.6671293 0.04492553 1.130428
##    g_cross_AUC  g_cross_r  k_cross_AUC k_cross_vals_med k_cross_vals_q1
## 1 0.0006782376 0.03889667 2.426612e-05      0.002336459    0.0005660821
##   k_cross_vals_q3 k_cross_vals_max K12_Diff_AUC k_k1k2_vals_med k_k1k2_vals_q1
## 1     0.005277495       0.00944047 0.0003790916      0.00594408    0.001634323
##   k_k1k2_vals_q3 k_k1k2_vals_max K1K12_Diff_AUC k_k1k12_vals_med
## 1     0.01270813      0.02151166   0.0003633184      0.005750551
##   k_k1k12_vals_q1 k_k1k12_vals_q3 k_k1k12_vals_max K2K12_Diff_AUC
## 1     0.001602771       0.0122064       0.02026278  -1.577328e-05
##   k_k2k12_vals_med k_k2k12_vals_q1 k_k2k12_vals_q3 k_k2k12_vals_max     pcf_AUC
## 1    -0.0001935285   -0.0005017328   -3.155209e-05                0 0.008457301
##   pcf_vals_med pcf_vals_q1 pcf_vals_q3 pcf_vals_max pcf_vals_min      pcf_r
## 1      1.21454    1.168805     1.22244     1.229431     1.091761 0.04445334
##     mrcf_AUC mrcf_vals_med mrcf_vals_q1 mrcf_vals_q3 mrcf_vals_max
## 1 0.01127915      1.228653      1.20611     1.274725      1.277776
##   mrcf_vals_min     mrcf_r      mccf_AUC mccf_vals_med mccf_vals_q1
## 1     0.8980466 0.02778333 -0.0003683821    0.05376596   0.05269271
##   mccf_vals_q3 mccf_vals_max mccf_vals_min     mccf_r     M_AUC M_vals_med
## 1   0.05565426    0.05800203    0.04952488 0.04445334 0.1063055   3.591923
##   M_vals_q1 M_vals_q3 M_vals_max M_vals_min     M_r      ITLR      ITLR2
## 1  3.280865  4.116922   4.611528  0.4818792 0.03334 0.1852679 0.07706592
##          BC  MH_index  JaccardJ SorensenL Moran_I_tumor Moran_I_immune
## 1 0.5185003 0.3257691 0.2122787 0.3502143    0.03291831      0.6420521
##   moran_I_Bivariate  geary_TC  geary_IC moran_HL_TC moran_HH_TC moran_LH_TC
## 1        0.06693746 0.9751893 0.5006019 0.003676471  0.02573529 0.009191176
##   moran_LL_TC geary_HH_TC geary_LL_TC geary_OP_TC geary_NE_TC moran_HL_IC
## 1 0.003676471  0.02389706 0.003676471 0.009191176 0.007352941           0
##   moran_HH_IC moran_LH_IC moran_LL_IC geary_HH_IC geary_LL_IC geary_OP_IC
## 1  0.07352941 0.007352941           0  0.06617647           0 0.003676471
##   geary_NE_IC moran_HH_TC_HH_IC moran_HH_TC_HL_IC moran_HH_TC_LH_IC
## 1           0       0.001102941                 0                 0
##   moran_HH_TC_LL_IC moran_HL_TC_HH_IC moran_HL_TC_HL_IC moran_HL_TC_LH_IC
## 1                 0                 0                NA                 0
##   moran_HL_TC_LL_IC moran_LH_TC_HH_IC moran_LH_TC_HL_IC moran_LH_TC_LH_IC
## 1                 0      0.0003676471                 0                 0
##   moran_LH_TC_LL_IC moran_LL_TC_HH_IC moran_LL_TC_HL_IC moran_LL_TC_LH_IC
## 1                 0                 0                NA                 0
##   moran_LL_TC_LL_IC geary_HH_TC_HH_IC geary_HH_TC_LL_IC geary_HH_TC_OP_IC
## 1                 0       0.005514706                 0                 0
##   geary_HH_TC_NE_IC geary_LL_TC_HH_IC geary_LL_TC_LL_IC geary_LL_TC_OP_IC
## 1                 0                 0                 0                 0
##   geary_LL_TC_NE_IC geary_OP_TC_HH_IC geary_OP_TC_LL_IC geary_OP_TC_OP_IC
## 1                NA                 0                 0                 0
##   geary_OP_TC_NE_IC geary_NE_TC_HH_IC geary_NE_TC_LL_IC geary_NE_TC_OP_IC
## 1                 0                 0                 0                 0
##   geary_NE_TC_NE_IC GetisOrd_HS GetisOrd_CS GetisOrd_CS_IC_HS_TC
## 1                NA 0.009191176           0                    0
##   GetisOrd_CS_TC_HS_IC GetisOrd_HS_IC GetisOrd_CS_IC GetisOrd_HS_TC
## 1                    0     0.07536765    0.005514706     0.04044118
##   GetisOrd_CS_TC GetisOrd_S_intra_cancer GetisOrd_S_intra_immune     Lee_L
## 1     0.01286765               0.9998912               0.9998912 0.1589278
##   Lee_HL_TC_IC Lee_HH_TC_IC Lee_LH_TC_IC Lee_LL_TC_IC Lee_HL_IC_TC Lee_HH_IC_TC
## 1  0.005514706   0.04779412   0.01838235  0.003676471   0.02205882   0.04227941
##   Lee_LH_IC_TC Lee_LL_IC_TC  sill_tumor  sill_immune range_tumor range_immune
## 1  0.005514706  0.005514706 1.22331e-05 0.0003285947  0.03298128   0.03490245
##   kappa_tumor kappa_immune   sill_IC_TC range_IC_TC kappa_IC_TC   sill_TC_IC
## 1           1            5 0.0003022043  0.03243775           5 1.153167e-05
##   range_TC_IC kappa_TC_IC kappa_IK   sill_IK  range_IK mean_x_weight_TC
## 1  0.01435864         4.2        1 0.2637792 0.1928726         341.9047
##   median_x_weight_TC sd_x_weight_TC iqr_x_weight_TC skewness_x_weight_TC
## 1           316.3526       189.5267        253.4453            0.7379734
##   kurtosis_x_weight_TC min_x_weight_TC max_x_weight_TC range_x_weight_TC
## 1             3.078021        46.42725        941.0975          888.2847
##   Q10_weight_TC Q20_weight_TC Q25_weight_TC Q30_weight_TC Q40_weight_TC
## 1      129.9211      180.4079      207.8196      232.3328      276.2156
##   Q60_weight_TC Q70_weight_TC Q75_weight_TC Q80_weight_TC Q90_weight_TC
## 1      364.2922      423.0589      444.1035      485.7368      598.8658
##   theil_index_weight_TC gini_coeff_weight_TC mean_x_closeness_TC
## 1             0.1876369            0.3007102        0.0009336501
##   median_x_closeness_TC sd_x_closeness_TC iqr_x_closeness_TC
## 1          0.0009218071      0.0001553146       0.0002475451
##   skewness_x_closeness_TC kurtosis_x_closeness_TC min_x_closeness_TC
## 1               0.1378892                2.074654       0.0006501667
##   max_x_closeness_TC range_x_closeness_TC Q10_closeness_TC Q20_closeness_TC
## 1        0.001222484         0.0005822904      0.000736942     0.0007896602
##   Q25_closeness_TC Q30_closeness_TC Q40_closeness_TC Q60_closeness_TC
## 1     0.0008037539     0.0008276245     0.0008790804     0.0009688396
##   Q70_closeness_TC Q75_closeness_TC Q80_closeness_TC Q90_closeness_TC
## 1      0.001035236      0.001060593      0.001083414      0.001155939
##   theil_index_closeness_TC gini_coeff_closeness_TC mean_x_betweenness_TC
## 1                0.1422839               0.0938724            0.06023753
##   median_x_betweenness_TC sd_x_betweenness_TC iqr_x_betweenness_TC
## 1              0.04720288          0.05340788           0.07404862
##   skewness_x_betweenness_TC kurtosis_x_betweenness_TC min_x_betweenness_TC
## 1                 0.8201344                  2.842056                    0
##   max_x_betweenness_TC range_x_betweenness_TC Q10_betweenness_TC
## 1            0.2013879              0.2013879       0.0009756387
##   Q20_betweenness_TC Q25_betweenness_TC Q30_betweenness_TC Q40_betweenness_TC
## 1         0.01213235         0.01654156         0.02337255         0.03363845
##   Q60_betweenness_TC Q70_betweenness_TC Q75_betweenness_TC Q80_betweenness_TC
## 1         0.06376951         0.07771271         0.09206894          0.1045411
##   Q90_betweenness_TC theil_index_betweenness_TC gini_coeff_betweenness_TC
## 1          0.1379019                  0.2927516                  0.483103
##   mean_x_degree_TC median_x_degree_TC sd_x_degree_TC iqr_x_degree_TC
## 1        0.1212121          0.1149577     0.03124014      0.04174963
##   skewness_x_degree_TC kurtosis_x_degree_TC min_x_degree_TC max_x_degree_TC
## 1            0.2111385             3.022713      0.06122449       0.1905842
##   range_x_degree_TC Q10_degree_TC Q20_degree_TC Q25_degree_TC Q30_degree_TC
## 1         0.1306689    0.08792271    0.09529212     0.1028497     0.1111111
##   Q40_degree_TC Q60_degree_TC Q70_degree_TC Q75_degree_TC Q80_degree_TC
## 1     0.1149577     0.1237245     0.1379493     0.1395349     0.1395349
##   Q90_degree_TC theil_index_degree_TC gini_coeff_degree_TC
## 1     0.1609408            0.09894185            0.1364111
##   mean_x_triangle_area_TC median_x_triangle_area_TC sd_x_triangle_area_TC
## 1                38044.83                  27469.38              36202.47
##   iqr_x_triangle_area_TC skewness_x_triangle_area_TC
## 1               35823.25                     1.48537
##   kurtosis_x_triangle_area_TC min_x_triangle_area_TC max_x_triangle_area_TC
## 1                    5.028701                1807.25                 164302
##   range_x_triangle_area_TC Q10_triangle_area_TC Q20_triangle_area_TC
## 1                 162182.7             7112.375              10863.6
##   Q25_triangle_area_TC Q30_triangle_area_TC Q40_triangle_area_TC
## 1             13345.37                15286             20370.55
##   Q60_triangle_area_TC Q70_triangle_area_TC Q75_triangle_area_TC
## 1             35461.45             44900.05             51195.44
##   Q80_triangle_area_TC Q90_triangle_area_TC theil_index_triangle_area_TC
## 1              59217.7             90076.45                    0.3679089
##   gini_coeff_triangle_area_TC mean_x_triangle_perimeter_TC
## 1                   0.4452052                     998.2516
##   median_x_triangle_perimeter_TC sd_x_triangle_perimeter_TC
## 1                       957.7757                   398.0856
##   iqr_x_triangle_perimeter_TC skewness_x_triangle_perimeter_TC
## 1                    540.3606                        0.4805242
##   kurtosis_x_triangle_perimeter_TC min_x_triangle_perimeter_TC
## 1                         2.584347                    309.7428
##   max_x_triangle_perimeter_TC range_x_triangle_perimeter_TC
## 1                    2024.183                      1741.031
##   Q10_triangle_perimeter_TC Q20_triangle_perimeter_TC Q25_triangle_perimeter_TC
## 1                  525.6501                  656.8388                  701.4646
##   Q30_triangle_perimeter_TC Q40_triangle_perimeter_TC Q60_triangle_perimeter_TC
## 1                  756.5406                  855.9714                  1051.601
##   Q70_triangle_perimeter_TC Q75_triangle_perimeter_TC Q80_triangle_perimeter_TC
## 1                  1162.411                  1240.914                   1341.49
##   Q90_triangle_perimeter_TC theil_index_triangle_perimeter_TC
## 1                  1643.694                         0.1631412
##   gini_coeff_triangle_perimeter_TC mean_x_weight_Lym median_x_weight_Lym
## 1                        0.2219247          559.5647              572.86
##   sd_x_weight_Lym iqr_x_weight_Lym skewness_x_weight_Lym kurtosis_x_weight_Lym
## 1        235.2004         339.0111              0.023169              1.915156
##   min_x_weight_Lym max_x_weight_Lym range_x_weight_Lym Q10_weight_Lym
## 1         158.1078           972.42           818.1371       275.4948
##   Q20_weight_Lym Q25_weight_Lym Q30_weight_Lym Q40_weight_Lym Q60_weight_Lym
## 1       341.8807       373.8321       442.7825        497.452        622.288
##   Q70_weight_Lym Q75_weight_Lym Q80_weight_Lym Q90_weight_Lym
## 1       708.5934        737.991       769.6201       861.7075
##   theil_index_weight_Lym gini_coeff_weight_Lym mean_x_closeness_Lym
## 1              0.1517951             0.2334459          0.001118417
##   median_x_closeness_Lym sd_x_closeness_Lym iqr_x_closeness_Lym
## 1            0.001090776       0.0002439847        0.0003185355
##   skewness_x_closeness_Lym kurtosis_x_closeness_Lym min_x_closeness_Lym
## 1              0.006142384                 1.959259        0.0006956157
##   max_x_closeness_Lym range_x_closeness_Lym Q10_closeness_Lym Q20_closeness_Lym
## 1         0.001442123           0.000704349       0.000793602      0.0009014683
##   Q25_closeness_Lym Q30_closeness_Lym Q40_closeness_Lym Q60_closeness_Lym
## 1      0.0009211277      0.0009442703       0.001029038       0.001176152
##   Q70_closeness_Lym Q75_closeness_Lym Q80_closeness_Lym Q90_closeness_Lym
## 1       0.001274133       0.001293406       0.001301062       0.001364034
##   theil_index_closeness_Lym gini_coeff_closeness_Lym mean_x_betweenness_Lym
## 1                 0.1523647                0.1182617              0.1013528
##   median_x_betweenness_Lym sd_x_betweenness_Lym iqr_x_betweenness_Lym
## 1               0.04756856            0.1213526             0.1348485
##   skewness_x_betweenness_Lym kurtosis_x_betweenness_Lym min_x_betweenness_Lym
## 1                   0.971388                   2.333333                     0
##   max_x_betweenness_Lym range_x_betweenness_Lym Q10_betweenness_Lym
## 1             0.3333333               0.3333333                   0
##   Q20_betweenness_Lym Q25_betweenness_Lym Q30_betweenness_Lym
## 1                   0                   0                   0
##   Q40_betweenness_Lym Q60_betweenness_Lym Q70_betweenness_Lym
## 1          0.01623377          0.08430769           0.1209091
##   Q75_betweenness_Lym Q80_betweenness_Lym Q90_betweenness_Lym
## 1           0.1545455           0.1733333           0.2212121
##   theil_index_betweenness_Lym gini_coeff_betweenness_Lym mean_x_degree_Lym
## 1                  0.08945023                  0.6253289         0.3528139
##   median_x_degree_Lym sd_x_degree_Lym iqr_x_degree_Lym skewness_x_degree_Lym
## 1           0.3452381       0.1435012        0.1785714            0.07244707
##   kurtosis_x_degree_Lym min_x_degree_Lym max_x_degree_Lym range_x_degree_Lym
## 1              2.104167        0.1666667        0.6041667          0.4201681
##   Q10_degree_Lym Q20_degree_Lym Q25_degree_Lym Q30_degree_Lym Q40_degree_Lym
## 1      0.1787879      0.2535714      0.2613636      0.2792208      0.3090909
##   Q60_degree_Lym Q70_degree_Lym Q75_degree_Lym Q80_degree_Lym Q90_degree_Lym
## 1      0.3909091      0.4279221      0.4545455      0.4545455      0.4916667
##   theil_index_degree_Lym gini_coeff_degree_Lym mean_x_triangle_area_Lym
## 1             0.05922949             0.1839387                 79444.65
##   median_x_triangle_area_Lym sd_x_triangle_area_Lym iqr_x_triangle_area_Lym
## 1                      58704                54331.6                52902.75
##   skewness_x_triangle_area_Lym kurtosis_x_triangle_area_Lym
## 1                    0.7979994                      2.14107
##   min_x_triangle_area_Lym max_x_triangle_area_Lym range_x_triangle_area_Lym
## 1                   15640                207540.5                  162110.5
##   Q10_triangle_area_Lym Q20_triangle_area_Lym Q25_triangle_area_Lym
## 1               24372.8                 36250               39309.5
##   Q30_triangle_area_Lym Q40_triangle_area_Lym Q60_triangle_area_Lym
## 1               43956.9               52201.5               78532.5
##   Q70_triangle_area_Lym Q75_triangle_area_Lym Q80_triangle_area_Lym
## 1               89436.4               99501.5                108968
##   Q90_triangle_area_Lym theil_index_triangle_area_Lym
## 1              144252.3                     0.2912646
##   gini_coeff_triangle_area_Lym mean_x_triangle_perimeter_Lym
## 1                    0.3554519                      1550.505
##   median_x_triangle_perimeter_Lym sd_x_triangle_perimeter_Lym
## 1                        1600.362                    454.2837
##   iqr_x_triangle_perimeter_Lym skewness_x_triangle_perimeter_Lym
## 1                     474.4855                          0.053512
##   kurtosis_x_triangle_perimeter_Lym min_x_triangle_perimeter_Lym
## 1                          1.916976                     1124.175
##   max_x_triangle_perimeter_Lym range_x_triangle_perimeter_Lym
## 1                     2296.585                       1223.054
##   Q10_triangle_perimeter_Lym Q20_triangle_perimeter_Lym
## 1                   1154.362                   1225.364
##   Q25_triangle_perimeter_Lym Q30_triangle_perimeter_Lym
## 1                   1315.593                   1317.962
##   Q40_triangle_perimeter_Lym Q60_triangle_perimeter_Lym
## 1                   1417.131                   1619.769
##   Q70_triangle_perimeter_Lym Q75_triangle_perimeter_Lym
## 1                   1768.688                   1828.992
##   Q80_triangle_perimeter_Lym Q90_triangle_perimeter_Lym
## 1                    1887.92                   2013.812
##   theil_index_triangle_perimeter_Lym gini_coeff_triangle_perimeter_Lym
## 1                          0.1687758                         0.1391456
##   num_homotypic_edges num_heterotypic_edges graph_assortativity mean_degree_TC
## 1                98.5                 156.5        -0.005663561       5.638937
##   mean_lcc_TC mean_degree_Lym mean_lcc_Lym mean_degree_Stroma mean_lcc_Stroma
## 1   0.4447567        5.531206    0.4565286             5.6325       0.4532165
##   mean_degree_Others mean_lcc_Others avg_prop_TC_neighbor_for_TC
## 1           5.577381       0.4589363                   0.4335639
##   avg_prop_Lym_neighbor_for_TC avg_prop_Stroma_neighbor_for_TC
## 1                   0.08363859                       0.3122982
##   avg_prop_Others_neighbor_for_TC avg_prop_TC_neighbor_for_Lym
## 1                      0.09094651                    0.4532738
##   avg_prop_Lym_neighbor_for_Lym avg_prop_Stroma_neighbor_for_Lym
## 1                    0.08273584                        0.3525794
##   avg_prop_Others_neighbor_for_Lym avg_prop_TC_neighbor_for_Stroma
## 1                       0.08365286                       0.4181597
##   avg_prop_Lym_neighbor_for_Stroma avg_prop_Stroma_neighbor_for_Stroma
## 1                       0.09413217                           0.3464766
##   avg_prop_Others_neighbor_for_Stroma avg_prop_TC_neighbor_for_Others
## 1                          0.09051435                       0.4356656
##   avg_prop_Lym_neighbor_for_Others avg_prop_Stroma_neighbor_for_Others
## 1                       0.08122294                            0.418835
##   avg_prop_Others_neighbor_for_Others infiltration_score_TC_Lym
## 1                          0.06378968                  8.333333
##   infiltration_score_TC_Stroma infiltration_score_TC_Others
## 1                     2.388715                         11.5
##   infiltration_score_Lym_TC infiltration_score_Lym_Stroma
## 1                 0.4627783                     0.4494949
##   infiltration_score_Lym_Others infiltration_score_Stroma_TC
## 1                             2                     1.317852
##   infiltration_score_Stroma_Lym infiltration_score_Stroma_Others
## 1                           8.5                                9
##   infiltration_score_Others_TC infiltration_score_Others_Lym
## 1                    0.4001536                           1.5
##   infiltration_score_Others_Stroma mean_x_cross_weight median_x_cross_weight
## 1                        0.5388994            257.1352              231.4548
##   sd_x_cross_weight iqr_x_cross_weight skewness_x_cross_weight
## 1          144.4707            158.072                1.429373
##   kurtosis_x_cross_weight min_x_cross_weight max_x_cross_weight
## 1                5.891466           17.72005           889.8029
##   range_x_cross_weight Q10_cross_weight Q20_cross_weight Q25_cross_weight
## 1             863.7312         87.11175         131.2741         150.1614
##   Q30_cross_weight Q40_cross_weight Q60_cross_weight Q70_cross_weight
## 1         164.8282         190.1411            262.2         292.7087
##   Q75_cross_weight Q80_cross_weight Q90_cross_weight theil_index_cross_weight
## 1         319.2488         344.8599         429.1093                0.1944182
##   gini_coeff_cross_weight  shannon shannonZ_entropy altieri_entropy_SMI
## 1               0.3218815 1.198687          1.93634          0.06840236
##   altieri_entropy_RES leibovici_entropy spat_diversity batty_entropy_TC
## 1             1.85931           2.27181       1.649454       -0.3319566
##   battyLISA_entropy_TC batty_entropy_Lym battyLISA_entropy_Lym mean_x_le_TC
## 1             6.262947         -1.285927              5.580511    0.8242515
##   median_x_le_TC sd_x_le_TC iqr_x_le_TC skewness_x_le_TC kurtosis_x_le_TC
## 1      0.9182958  0.5946244    1.298795       -0.2039206         1.873641
##   min_x_le_TC max_x_le_TC range_x_le_TC Q10_le_TC Q20_le_TC Q25_le_TC Q30_le_TC
## 1           0           2             2         0         0         0 0.6500224
##   Q40_le_TC Q60_le_TC Q70_le_TC Q75_le_TC Q80_le_TC Q90_le_TC theil_index_le_TC
## 1 0.9182958         1         1  1.298795  1.459148  1.548795         0.0389716
##   gini_coeff_le_TC mean_x_le_Lym median_x_le_Lym sd_x_le_Lym iqr_x_le_Lym
## 1        0.3996172      1.065975               1   0.5560298    0.6887219
##   skewness_x_le_Lym kurtosis_x_le_Lym min_x_le_Lym max_x_le_Lym range_x_le_Lym
## 1        -0.5801127          2.534307            0            2              2
##   Q10_le_Lym Q20_le_Lym Q25_le_Lym Q30_le_Lym Q40_le_Lym Q60_le_Lym Q70_le_Lym
## 1          0  0.7219281  0.8112781  0.9182958  0.9852281   1.351644   1.459148
##   Q75_le_Lym Q80_le_Lym Q90_le_Lym theil_index_le_Lym gini_coeff_le_Lym
## 1        1.5   1.530493   1.685816         0.04743391         0.2897993